﻿<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>会员卡</title>
		<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
		<link href="../css/style.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/utils.js"></script>
		<script type="text/javascript" src="../js/checkLogin.js"></script>
		<script type="text/javascript" src="../js/jquery.pager.js"></script>
		<script type="text/javascript" src="../js/pagination.js"></script>
		<script type="text/javascript" src="../js/shopSelecter.js"></script>
		<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
		<script type="text/javascript" src="../js/find.js"></script>
		<script type="text/javascript" src="../js/dataTable.js"></script>
		<script type="text/javascript" src="../js/qmsk-1.0.js"></script>
		<script type="text/javascript">
			$(function() {
				$('.doubledate').kuiDate({
					className : 'doubledate',
					isDisabled : "0" // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
				});

				qmsk.initSelect({
					url : '../memberState/find/all/0/100',
					id : 'searchMemberState',
					heads : ['id', 'name'],
					defaults : {
						key : '所有',
						value : ' '
					}
				});
				var shopId = $("#shopName").val();
				if (IsNotEmpty(shopId)) {
					qmsk.initSelect({
						url : '../memberLevel/find/memberLevelList/0/10?shopId=' + shopId,
						id : 'searchMemberLevel',
						heads : ['ID', 'Name'],
						defaults : {
							key : '请选择会员级别',
							value : ' '
						}
					});
				}
				initShopSelecter();
			});
			/**
			 * 初始化店面选择器
			 */
			function initShopSelecter() {
				refreshInput($(".serWrapper"));
				$("#shopIsChoosed").removeAttr("checked");
				$("#shopName").attr("disabled", "disabled");

				$("#shopIsChoosed").bind("click", function() {
					var checked = $(this).attr("checked");
					if (checked) {
						$("#shopName").removeAttr("disabled");
					} else {
						$("#shopName").attr("disabled", "disabled");
						$("#shopName").empty();
						$("#searchLeave").empty();
					}
				});
			}

			/**
			 * 店面选择后的回调函数，这里需要去加载会员级别下拉框
			 */
			function shopSelected(shopId, shopName) {
				qmsk.initSelect({
					url : '../memberLevel/find/memberLevelList/0/10?shopId=' + shopId,
					id : 'searchMemberLevel',
					heads : ['ID', 'Name'],
					defaults : {
						key : '请选择会员级别',
						value : ' '
					}
				});
			}

			/**
			 * 分页查询
			 */
			function search() {

				var shopId = $("#shopName").val();
				if (IsEmpty(shopId)) {
					shopId = '';
				}
				var customerName = $("#searchName").val();
				var mp = $("#searchMp").val();
				var memberCardNo = $("#searchMemberCardNo").val();
				var levelId = $("#searchMemberLevel").val();
				if (IsEmpty(levelId)) {
					levelId = '';
				}
				var status = $("#searchMemberState").val();
				if (IsEmpty(status)) {
					status = '';
				}

				var isWechat = $("#isWechat").val();
				if (IsEmpty(isWechat)) {
					isWechat = '';
				}

				var license = $("#searchLicense").val();

				var IntegralAmount1 = $("#searchIntegral1").val();
				var IntegralAmount2 = $("#searchIntegral2").val();
				var cashCouponAmount1 = $("#searchCashCoupon1").val();
				var cashCouponAmount2 = $("#searchCashCoupon2").val();
				var depositAmount1 = $("#searchDeposit1").val();
				var depositAmount2 = $("#searchDeposit2").val();
				var createFileTime1 = $("#createFileTime1").val();
				var createFileTime2 = $("#createFileTime2").val();

				qmsk.get('../memberQuery/find/amount', {
					shopId : shopId,
					customerName : customerName,
					mp : mp,
					memberCardNo : memberCardNo,
					levelId : levelId,
					status : status,
					license : license,
					IntegralAmount1 : IntegralAmount1,
					IntegralAmount2 : IntegralAmount2,
					cashCouponAmount1 : cashCouponAmount1,
					cashCouponAmount2 : cashCouponAmount2,
					depositAmount1 : depositAmount1,
					depositAmount2 : depositAmount2,
					createFileTime1 : createFileTime1,
					createFileTime2 : createFileTime2,
					isWechat : isWechat
				}, function(message) {

					//"depositAmountSum","cashCouponAmountSum",
					//"CouponAmountSum","consumeAmountSum","integralAmountSum"
					var depositAmountSum = getHtmlString(getHeadIndexValue(0, message, "depositAmountSum"));
					if (IsEmpty(depositAmountSum)) {
						$("#sum").hide();
						$("#noSum").show();
					} else {
						$("#sum").show();
						$("#noSum").hide();
					}

					var cashCouponAmountSum = getHtmlString(getHeadIndexValue(0, message, "cashCouponAmountSum"));
					var CouponAmountSum = getHtmlString(getHeadIndexValue(0, message, "CouponAmountSum"));
					var consumeAmountSum = getHtmlString(getHeadIndexValue(0, message, "consumeAmountSum"));
					var integralAmountSum = getHtmlString(getHeadIndexValue(0, message, "integralAmountSum"));
					var text = '储值总计：' + depositAmountSum;
					text += '    积分总计：' + integralAmountSum;
					text += '    代金券总计：' + cashCouponAmountSum;
					text += '    优惠券总计：' + CouponAmountSum;
					$("#sum").text(text);
				});

				new Pagination({
					url : '../memberQuery/find/list1',
					data : {
						shopId : shopId,
						customerName : customerName,
						mp : mp,
						memberCardNo : memberCardNo,
						levelId : levelId,
						status : status,
						license : license,
						IntegralAmount1 : IntegralAmount1,
						IntegralAmount2 : IntegralAmount2,
						cashCouponAmount1 : cashCouponAmount1,
						cashCouponAmount2 : cashCouponAmount2,
						depositAmount1 : depositAmount1,
						depositAmount2 : depositAmount2,
						createFileTime1 : createFileTime1,
						createFileTime2 : createFileTime2,
						isWechat : isWechat
					},
					success : printDataToPage,
					pagerHandler : 'pager'
				});
			}

			function printDataToPage(rst) {
				//"shopID","shopName","customerID","customerName","sex","mp","tel","birthday","rmail",
				//"zipCode","IDNumber","industryType","companyName","companyDuty","address","custFrom","levelID",
				//"levelName","memberFee","status","memberStateName","createFileTime","validDateTime",
				//"validityDay","memberCardNo","payPwd","password","memberMemo",
				//"depositAmount","cashCouponAmount","couponAmount","consumeAmount",
				//"integralAmount","discount","carTypeName","license"
				dataTable({
					tbodyId : 'memberList',
					heads : ["createFileTime", "memberCardNo", "customerName", "mp", "IDNumber", "levelName", "integralAmount", "depositAmount", "cashCouponAmount", "couponAmount", "discount", "license", "carTypeName", "memberStateName", ["shopID", "memberID", "customerID"]],
					rst : rst,
					sup : {
						id : 'sup',
						template : '共 [index] 条'
					},
					handler : [{
						col : 14,
						f : detailButton
					}]
				});
			}

			function detailButton(heads, row) {
				return "<input type='button' value='详情' onclick='toDetail(" + heads[0] + "," + heads[1] + "," + heads[2] + ");'  class='common_btn'>";
			}

			function toDetail(shopId, memberID, customerID) {
				qmsk.get('../memberQuery/find/detail/' + memberID + '/' + shopId, printDetailToPage);
				loadCarList(customerID);
				openDetailPanel();
			}

			/**
			 * 将详细信息显示到页面上
			 */
			function printDetailToPage(rst) {
				$("#addShopId").val(getHtmlString(getHeadIndexValue(0, rst, "shopName")));
				$("#addCustomerName").val(getHtmlString(getHeadIndexValue(0, rst, "customerName")));
				$("#addSex").val(getHtmlString(getHeadIndexValue(0, rst, "sex")));
				$("#addMp").val(getHtmlString(getHeadIndexValue(0, rst, "mp")));
				$("#addTel").val(getHtmlString(getHeadIndexValue(0, rst, "tel")));

				$("#addBirthday").val(getHtmlString(getHeadIndexValue(0, rst, "birthday")));
				$("#addEmail").val(getHtmlString(getHeadIndexValue(0, rst, "email")));
				$("#addZipCode").val(getHtmlString(getHeadIndexValue(0, rst, "zipCode")));

				$("#addIDNumber").val(getHtmlString(getHeadIndexValue(0, rst, "IDNumber")));
				$("#addIndustryType").val(getHtmlString(getHeadIndexValue(0, rst, "industryType")));
				$("#addCompanyName").val(getHtmlString(getHeadIndexValue(0, rst, "companyName")));

				$("#addCompanyDuty").val(getHtmlString(getHeadIndexValue(0, rst, "companyDuty")));
				$("#addAddress").val(getHtmlString(getHeadIndexValue(0, rst, "address")));
				$("#addCustomerFrom").val(getHtmlString(getHeadIndexValue(0, rst, "custFrom")));

				$("#addLevelId").val(getHtmlString(getHeadIndexValue(0, rst, "levelName")));
				$("#memberFee").val(getHtmlString(getHeadIndexValue(0, rst, "memberFee")));
				$("#addMemberStatus").val(getHtmlString(getHeadIndexValue(0, rst, "memberStateName")));

				$("#createFileTime").val(getHtmlString(getHeadIndexValue(0, rst, "createFileTime")));
				$("#validDay").val(getHtmlString(getHeadIndexValue(0, rst, "validityDay")));
				$("#validDateTime").val(getHtmlString(getHeadIndexValue(0, rst, "validDateTime")));

				$("#addMemberCardNO").val(getHtmlString(getHeadIndexValue(0, rst, "memberCardNo")));

				$("#addNote").val(getHtmlString(getHeadIndexValue(0, rst, "memberMemo")));
				$("#depositAmount").val(getHtmlString(getHeadIndexValue(0, rst, "depositAmount")));
				$("#couponAmount").val(getHtmlString(getHeadIndexValue(0, rst, "cashCouponAmount")));

				$("#consumeAmount").val(getHtmlString(getHeadIndexValue(0, rst, "consumeAmount")));
				$("#integralAmount").val(getHtmlString(getHeadIndexValue(0, rst, "integralAmount")));
				$("#discount").val(getHtmlString(getHeadIndexValue(0, rst, "discount")));
			}

			//------------------------会员详情----------------------------------------
			/**
			 * 显示详情面板
			 */
			function openDetailPanel() {
				$("#DetailPanel").show();
				$("#listPanel").hide();
			}

			/**
			 * 关闭详情面板
			 */
			function closeDetailPanel() {
				$("#DetailPanel").hide();
				$("#listPanel").show();
			}

			/**
			 * 加载车辆信息列表
			 */
			function loadCarList(customerId) {
				if (customerId == null) {
					return;
				}
				qmsk.get('../custCar/find/list/customerId/' + customerId, function(rst) {
					dataTable({
						tbodyId : 'customerCarTbody',
						heads : ["carTypeName", "license", "insuranceFirstDate", "insuranceEndDate", "recentlyDate", "checkCarDate"],
						rst : rst
					});
				});
			}
		</script>
	</head>
	<body>
		<div id="yinying"></div>
		<div id="yinying1"></div>

		<!-- 选择 商铺名称的列表 -->
		<div id="shopListPanel_yinying" class="yinying" style="z-index:100;"></div>
		<div id="shopListPanel" class="hideDiv">
			<div style="float: right; margin-bottom: 5px; width: 20px; height: 20px; line-height: 20px; text-align: center; background-color: #eee; margin-bottom: 5px; border: 1px solid #ccc;">
				<span id="shopListPanel_close" style="cursor: pointer; font-size: 14px;">X</span>
			</div>
			<div class="bottom_search">
				<div class="serWrapper" >
					<input type="text" id="shopListPanel_searchName" class="txt" >
					<strong class="refresh" onclick="$(this).prev().val('')">清空</strong>
				</div>
				<input type="button" id="shopListPanel_search"
				style="width: auto; margin-left: 5px;" value="查询"
				class="common_btn">
			</div>
			<table cellpadding="4" cellspacing="0" border="1" width="100%">
				<thead>
					<tr>
						<th>店面ID</th>
						<th>店面名称</th>
						<th>电话</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="shopListPanel_data" ></tbody>
			</table>
			<div id="shopPager" class="pager"></div>
		</div>

		<div class="container" id="container">

			<!-- 会员详情 -->
			<div class="container_R fr" id="DetailPanel" style="padding: 17px; width: 773px; display: none;">
				<div class="place">
					会员详情
					<a class="goHome"  href="javaScript:void(0);" onclick='closeDetailPanel()'>返回</a>
				</div>
				<div class="member_search">
					<p>
						<label><span>店面名称:</span>
							<input id="addShopId" readonly="readonly" />
						</label>
						<label><span>姓名:</span>
							<input type="text" id="addCustomerName"  readonly="readonly"  />
						</label>

						<label><span>性别:</span>
							<select  id="addSex" readonly="readonly">
								<option value="0">男</option>
								<option value="1">女</option>
							</select> </label>
					</p>
					<p>
						<label><span>手机:</span>
							<input type="text" id="addMp"  readonly="readonly"  />
						</label>
						<label><span>电话:</span>
							<input type="text" id="addTel" readonly="readonly"  />
						</label>
						<label><span>生日:</span>
							<input type="text"  id="addBirthday"  readonly="readonly" />
						</label>
					</p>
					<p>
						<label><span>Email:</span>
							<input type="text" id="addEmail"  readonly="readonly" />
						</label>
						<label><span>邮编:</span>
							<input type="text" id="addZipCode" readonly="readonly"  />
						</label>
						<label><span>身份证号码:</span>
							<input type="text" id="addIDNumber" readonly="readonly"  />
						</label>
					</p>
					<p>
						<label><span>行业:</span>
							<input type="text"  id="addIndustryType" readonly="readonly" />
						</label>
						<label><span>公司:</span>
							<input type="text" id="addCompanyName" readonly="readonly"  />
						</label>
						<label><span>职位:</span>
							<input type="text" id="addCompanyDuty" readonly="readonly"  />
						</label>
					</p>
					<p>
						<label><span>地址:</span>
							<input type="text" id="addAddress"  readonly="readonly" />
						</label>
						<label><span>客户来源:</span>
							<input type="text" id="addCustomerFrom" readonly="readonly"/>
						</label>
					</p>
					<p>
						<label><span>会员级别:</span>
							<input readonly="readonly" id="addLevelId"/>
						</label>
						<label><span>会员费:</span>
							<input type="text" readonly="readonly" id="memberFee"   />
						</label>
						<label><span>状态:</span>
							<input id="addMemberStatus" readonly="readonly"/>
						</label>
					</p>
					<p>
						<label><span>卡生效日期:</span>
							<input readonly="readonly" type="text" id="createFileTime"   />
						</label>
						<label><span>卡有效期:</span>
							<input readonly="readonly" type="text" id="validDay"   />
						</label>
						<label><span>卡失效期:</span>
							<input readonly="readonly" type="text" id="validDateTime"   />
						</label>
					</p>
					<p>
						<label><span>会员卡号:</span>
							<input type="text" id="addMemberCardNO"  readonly="readonly" />
						</label>
						<!-- <label><span>支付密码:</span>
						<input type="text"  id="addPayPwd"  />
						</label>
						<label><span>APP密码:</span>
						<input type="text" id="addPassword"   />
						</label> -->
					</p>
					<p>
						<label><span>会员备注:</span> 							<textarea id="addNote" readonly="readonly" style="width: 388px; height: 60px;"></textarea> </label>
					</p>
					<p>
						<label><span>储值（元）:</span>
							<input type="text" readonly="readonly" value="0" id="depositAmount"   />
						</label>
						<label><span>代金券（元）:</span>
							<input type="text" readonly="readonly" value="0" id="couponAmount"  />
						</label>
						<label><span>累计消费（元）:</span>
							<input type="text"  readonly="readonly" value="0" id="consumeAmount"   />
						</label>
					</p>
					<p>
						<label><span>积分:</span>
							<input type="text" readonly="readonly" value="0" id="integralAmount"   />
						</label>
						<label><span>折扣:</span>
							<input type="text" readonly="readonly" id="discount"   />
						</label>
					</p>

					<table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>车型</th>
								<th>车牌号</th>
								<th>首保日期</th>
								<th>保险到期</th>
								<th>保养日期</th>
								<th>年检日期</th>
							</tr>
						</thead>
						<tbody id="customerCarTbody"></tbody>
					</table>

					<table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0">
						<tbody>
							<tr>
								<th>服务编码</th>
								<th>服务名称</th>
								<th>次数</th>
								<th>剩余次数</th>
								<th>有效日期</th>
								<th>生效日期</th>
								<th>失效日期</th>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="submit_btn">
					<input type="button" value="返回" onclick="closeDetailPanel()" class="common_btn check_btn">
				</div>
			</div>

			<!-- 会员列表 -->
			<div class="container_R fr" id="listPanel" style="padding: 17px; width: 773px;">
				<div class="place">
					会员卡
				</div>
				<div class="member_search">
					<P>
						<span>
							<input type="checkbox" id="shopIsChoosed" style="width: auto; height: auto;border:none;">
							店面： </span>
						<select id="shopName" class="shopName" onclick="openShopListPanel(this)" style="height: 20px;"></select>
						<span>姓名：</span>
						<input type="text" id="searchName" />
						<span>手机：</span>
						<input type="text" id="searchMp" />
					</P>

					<p>
						<span>卡号：</span>
						<input type="text" id="searchMemberCardNo" />
						<span>会员级别：</span>
						<select id="searchMemberLevel"></select>
						<span>会员状态：</span>
						<select id="searchMemberState"></select>
					</P>
					<p>
						<span>储值 从：</span>
						<input type="text"  id="searchDeposit1" />
						<span>到：</span>
						<input type="text"  id="searchDeposit2" />
						<span>车牌号：</span>
						<input type="text" id="searchLicense" />
					</P>
					<p>
						<span>积分 从：</span>
						<input type="text"  id="searchIntegral1" />
						<span>到：</span>
						<input type="text"  id="searchIntegral2" />
						<span>会员来源：</span>
						<select id="isWechat">
							<option value="">全部会员</option>
							<option value="1">微信会员</option>
							<option value="0">非微信会员</option>
						</select>

					</p>
					<p>
						<span>代金券 从：</span>
						<input type="text"  id="searchCashCoupon1" />
						<span>到：</span>
						<input type="text"  id="searchCashCoupon2" />
					</p>
					<p>
						<span>入会日期 从：</span>
						<input type="text"  class="doubledate" id="createFileTime1" />
						<span>到：</span>
						<input type="text" class="doubledate"  id="createFileTime2" />
						<input type="button" class="btn" value="查询" onclick="search()">
					</p>
				</div>
				<table width="100%" class="member_list" cellpadding="0"
				cellspacing="1" border="0">
					<caption>
						<strong>会员列表 <span id="sup">共0条</span></strong>
					</caption>
					<thead>
						<tr>
							<th>入会日期</th>
							<th>卡号</th>
							<th>姓名</th>
							<th>手机</th>
							<th>身份证</th>
							<th>级别</th>
							<th>积分</th>
							<th>储值</th>
							<th>代金券</th>
							<th>优惠劵</th>
							<th>折扣</th>
							<th>车牌号</th>
							<th>车型</th>
							<th>状态</th>
							<th>详情</th>
						</tr>
					</thead>
					<tbody id="memberList"></tbody>
				</table>
				<div id="noSum"  class="Nothing" style="text-align:center;display: none;">
					无符合条件的数据！
				</div>
				<div id="sum"></div>
				<div id="pager" style="float: right;"></div>
			</div>
			<div class="fc"></div>
		</div>
		<!-- InstanceEndEditable -->
		<script type="text/javascript" src="../js/header.js"></script>
		<script type="text/javascript" src="../js/left.js"></script>
		<script type="text/javascript" src="../js/footer.js"></script>
		<script type="text/javascript">
			showTab(10, 4);
		</script>
	</body>
	<!-- InstanceEnd -->
</html>
